import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Headers } from '@nestjs/common';
import { Aaa3Service } from './aaa3.service';
import { CreateAaa3Dto } from './dto/create-aaa3.dto';
import { UpdateAaa3Dto } from './dto/update-aaa3.dto';
import { LoginRefreshGuard } from '../loginRefresh.guard';
import { LoginOneTokenRefresh } from '../loginOneTokenRefresh.guard';
import { AuthGuard } from '@nestjs/passport';
import { IsPublic } from '../is-public.decorator';

@Controller('aaa3')
export class Aaa3Controller {
  constructor(private readonly aaa3Service: Aaa3Service) {}

  @Post()
  create(@Body() createAaa3Dto: CreateAaa3Dto) {
    return this.aaa3Service.create(createAaa3Dto);
  }

  @Get()
  // @UseGuards(LoginRefreshGuard)
  @UseGuards(LoginOneTokenRefresh)
  findAll() {
    return this.aaa3Service.findAll();
  }

  @Get('list')
  @UseGuards(AuthGuard('jwt'))
  findList() {
    return this.aaa3Service.findAll();
  }

  @IsPublic()
  @Get('list2')
  // @UseGuards(AuthGuard('jwt'))
  findList2(@Headers() headers) {
    console.log(headers)
    return this.aaa3Service.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.aaa3Service.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateAaa3Dto: UpdateAaa3Dto) {
    return this.aaa3Service.update(+id, updateAaa3Dto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.aaa3Service.remove(+id);
  }
}
